<template>
  <div class="viewContain">
    <el-form :model="listQuery" size="small" label-width="100px">
      <el-row>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 6 }" :xl="{ span: 6 }">
          <el-form-item label="站点编号 :">
            <el-input
              v-model="listQuery.orgId"
              placeholder="请输入内容"
              clearable
              @keyup.enter.native="handleSearch"
            />
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 6 }" :xl="{ span: 6 }">
          <el-form-item label="站点名称 :">
            <el-input
              v-model="listQuery.name"
              placeholder="请输入内容"
              clearable
              @keyup.enter.native="handleSearch"
            />
          </el-form-item>
        </el-col>
        <el-col :xs="{ span: 24 }" :sm="{ span: 12 }" :md="{ span: 12 }" :xl="{ span: 12 }">
          <el-form-item>
            <el-button size="mini" type="primary" @click="handleSearch">查询</el-button>
            <el-button size="mini" type="primary" plain @click="handleReload">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table
      ref="table"
      v-loading="loading"
      fit
      stripe
      :data="tableData"
      border
      size="mini"
    >
      <el-table-column align="center" label="序号" type="index" width="50">
        <template slot-scope="scope">
          <span>{{ (listQuery.pageNo - 1) * listQuery.pageSize + scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="orgId" align="center" label="站点编号" />
      <el-table-column prop="name" align="center" label="站点名称" />
      <el-table-column align="center" fixed="right" label="操作" width="250">
        <template slot-scope="scope">
          <el-button class="text-button" size="mini" @click="handleRefundRecord(scope.row.orgId, scope.row.name)">退款记录</el-button>
          <el-button class="text-button" size="mini" @click="handlePurchaseRecord(scope.row.orgId)">采购记录</el-button>
          <el-button class="text-button" size="mini" @click="handleStockDetail(scope.row.orgId)">库存详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :total-count="totalCount"
      :page.sync="listQuery.pageNo"
      :limit.sync="listQuery.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { commonMixin } from '@v/mixin/commonMixin.js'
import ComApiUrl from '@a/comomApi.js'
import pagination from '@/components/pagination/index.vue'
export default {
  components: { pagination },
  mixins: [commonMixin],
  data() {
    return {
      comApiUrlList: new ComApiUrl('/member/api/purchase/querySite'),
      listQuery: {
        pageNo: 1,
        pageSize: 10,
        orgId: '' // 站点id
      }
    }
  },
  mounted() {
    const userInfo = JSON.parse(localStorage.getItem('userInfo'))
    // console.log(userInfo)
    const { isAdminRole, orgId } = userInfo
    if (isAdminRole !== '1') {
      console.log('进入站点页面')
      this.$router.push('/business/address/siter/' + orgId)
    }
    // this.listQuery.orgId = userInfo.orgId
    this.getList()
  },
  methods: {
    getList() {
      this.getInfo()
    },
    // 退款记录
    handleRefundRecord(orgId, name) {
      localStorage.setItem('orgName', name)
      this.$router.push('/business/address/refund/' + orgId)
    },
    // 采购记录
    handlePurchaseRecord(orgId) {
      this.$router.push('/business/address/purchase/' + orgId)
    },
    // 库存详情
    handleStockDetail(orgId, name) {
      this.$router.push('/business/address/stock/' + orgId)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
